package com.ebupt.migu.music.api.controller;

import com.ebupt.migu.music.api.entity.BannerApiResponse;
import com.ebupt.migu.music.api.entity.UserContentRequest;
import com.ebupt.migu.music.api.service.BannerService;
import com.ebupt.migu.music.autoTri.config.KafkaSender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.*;
import java.util.Map;

/**
 * Created by Intellij IDEA.
 * User:  liuyangyang@cd.ebupt.com
 * Date:  2019/10/18
 */
@Slf4j
@RestController
@RequestMapping("/musiclabel")
public class BannerController {

    @Autowired
    private BannerService bannerService;
    @Autowired
    private KafkaSender kafkaSender;

    /**
     * banner、音乐之声用户登录查询运营策略
     *
     * @return
     */
    @RequestMapping("/usercontent")
    public BannerApiResponse usercontent(@RequestBody UserContentRequest userContentRequest) {
        log.info("Banner/音乐之声登录访问，访问参数：{}", userContentRequest.toString());
        return bannerService.usercontent(userContentRequest);
    }

    @RequestMapping("/getUserRelationVal")
    public BannerApiResponse getUserRelationVal(@RequestBody Map param) {
        log.info("进入查询统一标签平台接口中客群保存的值，访问参数：{}", param.toString());
        return bannerService.getUserRelationVal(param);
    }

    @GetMapping("/send")
    public void sender(String topic, String jsonString) {
        log.info("topic:{}，jsonString：{}", topic, jsonString);
        kafkaSender.pro_test(topic, jsonString);
    }
}
